﻿#include "QMyCrossItem.h"

QMyCrossItem::QMyCrossItem()
{
   m_scale=1.0;
   selectype=false;
}

QRectF QMyCrossItem::boundingRect() const
{
    return QRectF(-20/m_scale,-20/m_scale,40/m_scale,40/m_scale);
}

void QMyCrossItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    pen.setWidth(2/m_scale);
    if (selectype)
        pen.setColor(Qt::green);
    else
        pen.setColor(Qt::red);

    QPainterPath path;
    path.moveTo(-20/m_scale,0);
    path.lineTo(20/m_scale,0);

    path.moveTo(0,-20/m_scale);
    path.lineTo(0,20/m_scale);

    painter->setPen(pen);
    painter->drawPath(path);
    //painter->drawRect(boundingRect());
}


void QMyCrossItem::setitemscale(qreal scale)
{
    m_scale=scale;
}

void QMyCrossItem::setselcetype(bool type)  {   selectype=type; }
